package com.tpolteam.tpol.tpol2019.demo.mvp

import android.os.Bundle
import android.os.PersistableBundle
import androidx.appcompat.app.AppCompatActivity

/**
 * @author Liangbo.Xu
 * @create 2020/7/13
 * @Describe desc
 */
abstract class MVPBaseActivity<V, T : BasePresenter<V>>(contentLayoutId: Int) : AppCompatActivity() {

    protected lateinit var mPresenter: T

    override fun onCreate(savedInstanceState: Bundle?, persistentState: PersistableBundle?) {
        super.onCreate(savedInstanceState, persistentState)
        mPresenter = createPresenter()
        mPresenter.attachView(this as V)
    }

    override fun onDestroy() {
        super.onDestroy()
        mPresenter.detachView()
    }

    protected abstract fun createPresenter(): T


}